#include <stdlib.h>

#include "lib.h"
#include "log.h"

#include "slotguts.h"
#include "hrollerguts.h"
#include "slotspin.h"
#include "getrand.h"


#define GUTSMIN		1700
#define GUTSMAX		1707

enum WheelContents {
	BLANK = 0,
	LAVALAMP,
	BUTTERFLY,
	SHIRT,
	PEACESIGN,	// Wild icon
	VWBUS,
};

enum SpinResult
{
	EVT_LOSER = 0,
	EVT_3LAVALAMP,
	EVT_3BUTTERFLY,
	EVT_3SHIRT,
	EVT_3VWBUS,
	EVT_3VWBUS5,
	NUMEVENTS
};

bool8 
HRollerSlotGuts::isValidGuts()
{
    return ((getGutsId() >= GUTSMIN) && (getGutsId() <= GUTSMAX));
}

uint8
HRollerSlotGuts::classifyStops(uint8* stops,uint8 bet, uint8 line)
{
	uint8 result = EVT_LOSER;

	int numButterfly = 0;
	int numLavalamp = 0;
	int numShirt = 0;
	int numWild = 0;
	int numVWbus = 0;

//	Log::msgInformation("HRollersSlotGuts::classifyStops- line %d", line+1);

    //  Do a preliminary run-through
    for ( uint8 i = 0; i < getReelCount(); i++ )
    {
        // Set the icon flags;
        switch ( getIcon(i, stops[i])->iconid )
        {
			case BUTTERFLY:
//				Log::msgInformation("reel %d %s ", i, "BUTTERFLY");
				++numButterfly;
				break;
			case LAVALAMP:
//				Log::msgInformation("reel %d %s ", i, "LAVALAMP");
				++numLavalamp;
				break;
			case SHIRT:
//				Log::msgInformation("reel %d %s ", i, "SHIRT");
				++numShirt;
				break;
			case PEACESIGN:
//				Log::msgInformation("reel %d %s ", i, "PEACESIGN");
				++numWild;
				break;
			case VWBUS:
//				Log::msgInformation("reel %d %s ", i, "VWBUS");
				++numVWbus;
				break;
        }
    }

	if ((numVWbus + numWild) == 3)
	{
		if (line < 4)
		{
//			Log::msgInformation("result %s", "EVT_3VWBUS");
			result = EVT_3VWBUS;
		}
		else
		{
//			Log::msgInformation("result %s", "EVT_3VWBUS5");
			result = EVT_3VWBUS5;
		}
	}
	if (((numShirt + numWild) == 3) && (result == EVT_LOSER))
	{
//		Log::msgInformation("result %s", "EVT_3SHIRT");
		result = EVT_3SHIRT;
	}
	if (((numButterfly + numWild) == 3) && (result == EVT_LOSER))
	{
//		Log::msgInformation("result %s", "EVT_3BUTTERFLY");
		result = EVT_3BUTTERFLY;
	}
	if (((numLavalamp + numWild) == 3) && (result == EVT_LOSER))
	{
//		Log::msgInformation("result %s", "EVT_3LAVALAMP");
		result = EVT_3LAVALAMP;
	}

	return result;
}


